import request from '@/utils/request'

// 定义返回的参数类型
export interface CategoryData {
  id: number,
  name: string,
  category1Id?:number,
  category2Id?:number
}

export default {
  /**
   * @description 获取一级分类列表
   * @url http://39.98.123.211:8510/admin/product/getCategory1
   * @returns Promise<CategoryData[]>
   */
  getCategory1(){
    return request.get<any,CategoryData[]>('/admin/product/getCategory1')
  },

  
  /**
   * @description 获取二级分类列表
   * @url http://39.98.123.211:8510/admin/product/getCategory2/2
   * @param category1Id 一级分类id
   * @returns Promise<CategoryData[]>
   */
  getCategory2(category1Id:number){
    return request.get<any,CategoryData[]>(`/admin/product/getCategory2/${category1Id}`)
  },


  /**
   * @description 获取三级分类列表
   * @uri http://39.98.123.211:8510/admin/product/getCategory3/1
   * @param category2Id 二级分类id
   * @returns Promise<CategoryData[]>
   */
  getCategory3(category2Id:number){
    return request.get<any,CategoryData[]>(`/admin/product/getCategory3/${category2Id}`)
  }
}